package com.wjk.kylin.mall.admin.controller;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.wjk.kylin.mall.admin.beanmapper.OauthClientEntityMapper;
import com.wjk.kylin.mall.admin.entity.OauthClientEntity;
import com.wjk.kylin.mall.admin.service.IOauthClientService;
import com.wjk.kylin.mall.admin.service.IRoleMenuService;
import com.wjk.kylin.mall.common.core.bo.admin.OAuth2ClientBO;
import com.wjk.kylin.mall.common.core.dto.admin.OAuth2ClientInDTO;
import com.wjk.kylin.mall.common.core.dto.base.BaseOutDTO;
import com.wjk.kylin.mall.common.core.dto.base.DataOutDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangjinkui
 * @since 2021-11-28
 */
@RestController
@RequestMapping("/oauth2")
public class OauthClientController {

    @Autowired
    private IOauthClientService oauthClientService;
    /**
     * 获取 OAuth2 客户端认证信息
      * @param inDTO
     * @return
     */
    @PostMapping("/getOAuth2ClientById")
    public BaseOutDTO getOAuth2ClientById(@RequestBody OAuth2ClientInDTO inDTO) {
        OauthClientEntity client = oauthClientService.getById(inDTO.getClientId());
        OAuth2ClientBO oAuth2ClientBO = OauthClientEntityMapper.INSTANCE.entity2BO(client);
        return DataOutDTO.builder().data(oAuth2ClientBO).build();
    }

}

